#include <stdio.h>

void bubble_sort(int a[], int size);
void show(int *arr, int len);

int main()
{
    int a[7] = {1, 2, 4, 5, 3, 9, 8};
    //数组长度
    int num = sizeof(a) / sizeof(a[0]);

    bubble_sort(a, num);

    show(a, num);

    return 0;
}

void bubble_sort(int a[], int size)
{
    for (int i = 0; i < size - 1; ++i)
    {
        for (int j = 0; j < size - 1 - i; ++j)
        {
            if (a[j] > a[j + 1])
            {
                int temp = a[j + 1];
                a[j + 1] = a[j];
                a[j] = temp;
            }
        }
    }
}

void show(int *arr, int len)
{
    for (int i = 0; i < len; i++)
    {
        printf("%d ", arr[i]);
    }
    printf("\n");
}
